package com.example.demo4.controller;

import com.example.demo4.entity.Book;
import com.example.demo4.service.BookService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
//import org.junit.jupiter.api.Test;

/**
 * @author: lin
 * @description: 用于测试
 * @time: 2021/7/30 9:26
 */
@RestController
public class testController {
    @Autowired
    private BookService bookService;
    @RequestMapping("/login")
    public String login(String email, String password){
        System.out.println("email是"+email);
        System.out.println("password是"+password);

        List<Book> books = bookService.selectAll();
        Collections.shuffle(books);
        for (int i = 0; i < books.size(); i++) {
            System.out.println(books.get(i).getName());
        }
        return "登录成功";
    }

    /*public static void main(String[] args) {

    }*/
    @Test
    public void test(){
        String [] strArr = {"1","2","3","4","5"};
        List<String> asList = Arrays.asList(strArr);
        ArrayList<Object> list = new ArrayList<>();
        list.add("小明");
        list.add("小白");
        list.add("小红");
        list.add("小绿");
        Collections.shuffle(list);
        System.out.println("get(1)"+list.get(1));
        System.out.println(StringUtils.strip(list.toString(),"[]"));

//让List 无序
//asList 其实是一种适配器模式,它内部其实还是数组
        Collections.shuffle(asList);
        for (String str : strArr) {
            System.out.println(str);
        }
        System.out.println(asList);
        //bookService.selectAll();
        System.out.println("lin");
    }


}
